﻿using Day25WebAPI.Adapters;
using Day25WebAPI.Adapters.Data;
using Day25WebAPI.Models;
using Day25WebAPI.Extensions;
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace Day25WebAPI.Controllers
{
    public class MessageController : ApiController
    {
        private IMessageAdapter _adapter;

        public MessageController()
        {
            _adapter = new MessageDataAdapter();
        }

        public IHttpActionResult Get()
        {
            List<MessageViewModel> models = _adapter.GetMessageViewModels();

            //Format the object like Firebase does it just to make it a little bit easier to change our JavaScript API calls
            var result = models.ToFirebaseResult(m => m.FirebaseName);

            return Ok(result);
        }
    }
}
